<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>『 知音培训信息管理平台』</title>

	<script type="text/javascript" src="__PUBLIC__/Resourse/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" charset="UTF-8" src="__PUBLIC__/Resourse/js/jquery.cookie.js"></script>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Resourse/themes/default/easyui.css" id="easyuiTheme">
	<script type="text/javascript" charset="UTF-8" src="__PUBLIC__/Resourse/js/changeEasyuiTheme.js"></script>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Resourse/themes/icon.css">
	<script type="text/javascript" src="__PUBLIC__/Resourse/js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/Resourse/js/jquery.portal.js"></script>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Resourse/css/index.css">
	<style>
		.layout-button-up{
			background: url('__PUBLIC__/Resourse/themes/gray/images/layout_arrows.png') no-repeat -16px 0;
		}
		.layout-button-down{
			background: url('__PUBLIC__/Resourse/themes/gray/images/layout_arrows.png') no-repeat -16px -16px;
		}
		.layout-button-left{
			background: url('__PUBLIC__/Resourse/themes/gray/images/layout_arrows.png') no-repeat 0 0;
		}
		.layout-button-right{
			background: url('__PUBLIC__/Resourse/themes/gray/images/layout_arrows.png') no-repeat 0 -16px;
		}
		.cs-north-bg {
			width: 100%;
			height: 100%;
			background: url(__PUBLIC__/Resourse/themes/gray/images/header_bg.png) repeat-x;
		}
		.title{
			font-size:16px;
			font-weight:bold;
			padding:20px 10px;
			background:#eee;
			overflow:hidden;
			border-bottom:1px solid #ccc;
		}
		.t-list{
			padding:5px;
		}
	</style>
	<script type="text/javascript">
		
		function addTab(title, url){
			if ($('#tabs').tabs('exists', title)){
				$('#tabs').tabs('select', title);//选中并刷新
				var currTab = $('#tabs').tabs('getSelected');
				var url = $(currTab.panel('options').content).attr('src');
				if(url != undefined && currTab.panel('options').title != 'Home') {
					$('#tabs').tabs('update',{
						tab:currTab,
						options:{
							content:createFrame(url)
						}
					})
				}
			} else {
				var content = createFrame(url);
				$('#tabs').tabs('add',{
					title:title,
					content:content,
					closable:true
				});
			}
			tabClose();
		}
		function createFrame(url) {
			var s = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:99%;border:0;"></iframe>';
			return s;
		}
				
		function tabClose() {
			/*双击关闭TAB选项卡*/
			$(".tabs-inner").dblclick(function(){
				var subtitle = $(this).children(".tabs-closable").text();
				$('#tabs').tabs('close',subtitle);
			})
			/*为选项卡绑定右键*/
			$(".tabs-inner").bind('contextmenu',function(e){
				$('#mm').menu('show', {
					left: e.pageX,
					top: e.pageY
				});
		
				var subtitle =$(this).children(".tabs-closable").text();
		
				$('#mm').data("currtab",subtitle);
				$('#tabs').tabs('select',subtitle);
				return false;
			});
		}		
		//绑定右键菜单事件
		function tabCloseEven() {
			//刷新
			$('#mm-tabupdate').click(function(){
				var currTab = $('#tabs').tabs('getSelected');
				var url = $(currTab.panel('options').content).attr('src');
				if(url != undefined && currTab.panel('options').title != 'Home') {
					$('#tabs').tabs('update',{
						tab:currTab,
						options:{
							content:createFrame(url)
						}
					})
				}
			})
			//关闭当前
			$('#mm-tabclose').click(function(){
				var currtab_title = $('#mm').data("currtab");
				$('#tabs').tabs('close',currtab_title);
			})
			//全部关闭
			$('#mm-tabcloseall').click(function(){
				$('.tabs-inner span').each(function(i,n){
					var t = $(n).text();
					if(t != 'Home') {
						$('#tabs').tabs('close',t);
					}
				});
			});
			//关闭除当前之外的TAB
			$('#mm-tabcloseother').click(function(){
				var prevall = $('.tabs-selected').prevAll();
				var nextall = $('.tabs-selected').nextAll();		
				if(prevall.length>0){
					prevall.each(function(i,n){
						var t=$('a:eq(0) span',$(n)).text();
						if(t != 'Home') {
							$('#tabs').tabs('close',t);
						}
					});
				}
				if(nextall.length>0) {
					nextall.each(function(i,n){
						var t=$('a:eq(0) span',$(n)).text();
						if(t != 'Home') {
							$('#tabs').tabs('close',t);
						}
					});
				}
				return false;
			});
			//关闭当前右侧的TAB
			$('#mm-tabcloseright').click(function(){
				var nextall = $('.tabs-selected').nextAll();
				if(nextall.length==0){
					//msgShow('系统提示','后边没有啦~~','error');
					alert('后边没有啦~~');
					return false;
				}
				nextall.each(function(i,n){
					var t=$('a:eq(0) span',$(n)).text();
					$('#tabs').tabs('close',t);
				});
				return false;
			});
			//关闭当前左侧的TAB
			$('#mm-tabcloseleft').click(function(){
				var prevall = $('.tabs-selected').prevAll();
				if(prevall.length==0){
					alert('到头了，前边没有啦~~');
					return false;
				}
				prevall.each(function(i,n){
					var t=$('a:eq(0) span',$(n)).text();
					$('#tabs').tabs('close',t);
				});
				return false;
			});
		
			//退出
			$("#mm-exit").click(function(){
				$('#mm').menu('hide');
			})
		}
		
		$(function() {
			tabCloseEven();
		
			$('.cs-navi-tab').click(function() {
				var $this = $(this);
				var href = $this.attr('src');
				var title = $this.text();
				addTab(title, href);
			});
		
			var skins = $('.li-skinitem span').click(function() {
				//debugger;
				var $this = $(this);
				if($this.hasClass('cs-skin-on')) return;
				skins.removeClass('cs-skin-on');
				$this.addClass('cs-skin-on');
				var skin = $this.attr('rel');
				if(skin === undefined) return;
				changeThemeFun(skin);
				//$('#swicth-style').attr('href', themes[skin]);
				//setCookie('cs-skin', skin);
				//skin == 'dark-hive' ? $('.cs-north-logo').css('color', '#FFFFFF') : $('.cs-north-logo').css('color', '#000000');
			});
			
			function expandAll(){
				var node = $('#tt').tree('getSelected');
				if (node){
					$('#tt').tree('expandAll', node.target);
				} else {
					$('#tt').tree('expandAll');
				}
			}

		});

		$(document).ready(function(){
			$('#tt').tree({  
			    url:'__URL__/menu/'  
			}); 
		
			$('#tt').tree({
				onClick: function(node){
					//alert(node.attributes);  // alert node text property when clicked
					if(node.attributes === undefined) return;
					var href = '__APP__/'+ node.attributes + '/index/';
					addTab(node.text, href);
				}
			});
			
			//alert("current skins:" +$.cookie('easyuiThemeName'));
			//var skin = $.cookie('easyuiThemeName');
			//changeThemeFun(skin);
			//if (typeof skin == undefined) {//获取用户设置的skin
				//if($.cookie('easyuiThemeName') === undefined) return;
				
			//	alert(skin);
			//	changeThemeFun(skin);
			//}
			var skin = $.cookie('easyuiThemeName');
			if (skin != null && typeof skin != undefined) {
				//alert(skin);
				//debugger;
				
				changeThemeFun(skin);
			}
			//expandAll();
			
		});
		
		var itemUrl = "";
		function fleshVerify(){
			//重载验证码
			var timenow = new Date().getTime();
			$('#verifyImg').attr('src','__URL__/verify/'+timenow);
		}	
		
	    function startChgPwd(){  
	        $('#dlgChgPwd').dialog('open').dialog('setTitle','修改密码');  
	        $('#fmChgPwd').form('clear');  
	        fleshVerify();
	        itemUrl = '__URL__/changePwd'; 
	    }  
		
	    function saveChgPwd(){  
           $('#fmChgPwd').form('submit',{  
               	url: itemUrl,  
                onSubmit: function(){  
                   return $(this).form('validate');  
                },  
                success: function(result){  
                    var result = eval('('+result+')');  
                    if (result.success){  
                    	$.messager.alert('消息','操作成功!','info');
                        $('#dlgChgPwd').dialog('close');      // close the dialog  		
                    } else {  
                        $.messager.show({  
	                           title: 'Error',  
	                           msg: result.errorMsg  
	                    });  
                    }  
                }  
            });  
	      }
	    
	    function chgProfile(){  
	        $('#dlgProfile').dialog('open').dialog('setTitle','修改密码');
	        $('#fmProfile').form('load','__URL__/profile');  
	        
	        //$('#fmProfile').form('clear');  
	        itemUrl = '__URL__/changeProfile'; 
	    }  
		
	    function saveProfile(){  
           $('#fmProfile').form('submit',{  
               	url: itemUrl,  
                onSubmit: function(){  
                   return $(this).form('validate');  
                },  
                success: function(result){  
                    var result = eval('('+result+')');  
                    if (result.success){  
                    	$.messager.alert('消息','操作成功!','info');
                        $('#dlgProfile').dialog('close');      // close the dialog  		
                    } else {  
                        $.messager.show({  
	                           title: 'Error',  
	                           msg: result.errorMsg  
	                    });  
                    }  
                }  
            });  
	      }
	    
	    function logout(){
            $.messager.confirm('确认','确认要退出本系统吗?',function(r){             	
                if (r){     
			    	$.ajax({
			    	   type: "POST",
			    	   url: "__URL__/logout/",
			    	   success: function(result){
			    		   var result = eval('('+result+')');  
		                    if (result.success){  
		                    	$.messager.alert('消息','退出成功!','info');
		                    	window.location.href='__URL__/login/';
		                    } else {  
		                        $.messager.show({  title: 'Error', msg: result.errorMsg  });  
		                    }  
			    	   }
			    	});
                }
            });   
	    }
	    //=====================================================
		$(function(){
			/*
			$('#pp').portal({
				border:false,
				fit:true,
				onStopDrag:getLayout
			});
			//初始化大框架后，添加portal元素
			add();*/
		});
		
		function add(){
			//读取布局字符串，循环添加portal对象
			$.ajax({
				url:'__PUBLIC__/Resourse/json/portal.json',
				success:function(data){
					debugger;
					var p = eval("("+data+")");
					
					$.each(p,function(i,panel){
						$.each(panel,function(j,option){
							var p = $('<div/>').appendTo('body');
							option["onClose"] = getLayout;
							p.panel(option);
							$('#pp').portal('add', {
								panel:p,
								columnIndex:i
							});
						});
					});
					$('#pp').portal('resize');
				},error:function(XmlHttpRequest,textStatus, errorThrown){
					var msg = XmlHttpRequest.responseText;
					debugger;
					var p = eval("("+msg+")");
					
					$.each(p,function(i,panel){
						$.each(panel,function(j,option){
							var p = $('<div/>').appendTo('body');
							option["onClose"] = getLayout;
							p.panel(option);
							$('#pp').portal('add', {
								panel:p,
								columnIndex:i
							});
						});
					});
					$('#pp').portal('resize');
                }
			});
		}
		
		function remove(){
			$('#pp').portal('remove',$('#pgrid'));
			$('#pp').portal('resize');
		}
		//获取布局
		function getLayout(){
			//$(this).panel("destroy");
			//获取布局。返回的是一个json类型的字符串。可以通过eval转换成json对象.也可以把此字符串存入数据库
			var portalLayot =  $('#pp').portal("getLayout");
			alert(portalLayot);
			alert(eval("("+portalLayot+")"));
		}
		//根据title获取不同的portal
		function getPanelForTitle(){
			alert($('#pp').portal("getPanelForTitle","Clock").panel("options").title);
			$('#pp').portal("getPanelForTitle","Title2").panel("open");
		}
		
	</script>

</head>

<body class="easyui-layout" style="border-width:50px;margin:0;">
	<div data-options="region:'north'" style="height:79px;overflow: hidden;" class="cs-north">
		<div class="cs-north-bg">
			<div class="nav" style="text-align:right">
				欢迎你！{$Think.session.loginUserName}
				<a href="#" onclick="startChgPwd()"><img src="__PUBLIC__/images/checked_out.png" width="16" height="16" border="0" alt="" align="absmiddle"> 修改密码</a> 
				<a href="#" onclick="chgProfile()"><img SRC="__PUBLIC__/images/write.gif" WIDTH="17" HEIGHT="16" BORDER="0" ALT="" align="absmiddle"> 修改资料</a> 
				<a href="#"  onclick="logout()"><img SRC="__PUBLIC__/images/error.gif" WIDTH="20" HEIGHT="20" BORDER="0" ALT="" align="absmiddle"> 退 出</a>
			</div>
			<div class="cs-north-logo"></div>
			<!-- jQuery EasyUI Portal<input type="button" value="getLayout" onclick="getLayout()"><input type="button" value="getPanelForTitle" onclick="getPanelForTitle()"> -->
			<ul class="ui-skin-nav">				
				<li class="li-skinitem" title="gray"><span class="gray" rel="gray"></span></li>
				<li class="li-skinitem" title="default"><span class="default" rel="default"></span></li>
				<li class="li-skinitem" title="bootstrap"><span class="bootstrap" rel="bootstrap"></span></li>
				<li class="li-skinitem" title="black"><span class="black" rel="black"></span></li>
				<li class="li-skinitem" title="metro"><span class="metro" rel="metro"></span></li>
			</ul>
		</div>
	</div>
	<div region="west" split="true" title="功能列表" style="width:200px;padding:10px;" class="cs-west">
			<ul id="tt"></ul>  
	</div>
	<div id="mainPanle"  region="center" border="true" title="操作区域" >
		 <div id="tabs" class="easyui-tabs"  fit="true" border="false"  style="overflow: hidden; width: 100%; height: auto;">

				<div id="pp" title="Home" style="position:relative">
					<div style="width:30%;"></div>
					<div style="width:40%;"></div>
					<div style="width:30%;"></div>
				</div>
        </div>
	</div>

	<div region="south"  style="height: 28px;overflow: hidden;" 
			class="panel-body panel-body-noheader layout-body">
		<div class="panel-header panel-header-noborder" style="text-align: center;">
				Copyright @ 2013 ZHIYIN
		</div>
	</div>
	<div id="mm" class="easyui-menu cs-tab-menu">
		<div id="mm-tabupdate">刷新</div>
		<div class="menu-sep"></div>
		<div id="mm-tabclose">关闭</div>
		<div id="mm-tabcloseother">关闭其他</div>
		<div id="mm-tabcloseall">关闭全部</div>
	</div>
	<div id="dlgChgPwd" class="easyui-dialog" style="width:400px;height:255px;padding:10px 20px"  closed="true" buttons="#dlgChgPwd-buttons">  
        <form id="fmChgPwd" class="formStyle"  method="post" novalidate> 
            <div class="fitem">  
                <label>旧密码:</label>  
                <input name="oldpassword" type="password"  class="easyui-validatebox" data-options="required:true" missingMessage="不能为空" > 
            </div>  
            <div class="fitem">  
                <label>新密码:</label>  
                <input name="password" type="password"  class="easyui-validatebox" data-options="required:true" missingMessage="不能为空" >
            </div>  
            <div class="fitem">  
                <label>确认新密码:</label>  
                <input name="repassword" type="password"  class="easyui-validatebox"  data-options="required:true" missingMessage="不能为空" >
            </div>  
            <div class="fitem">  
                <label>验证码:</label>  
                <input name="verify" class="easyui-validatebox" data-options="required:true">  
                <img SRC="__URL__/verify/" BORDER="0" ALT="点击刷新验证码" id="verifyImg" onClick="fleshVerify()" style="cursor:pointer" align="absmiddle">
            </div>     
        </form>  
    </div>  
    <div id="dlgChgPwd-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveChgPwd()">修改</a>  
       	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlgChgPwd').dialog('close')">取消</a>  
    </div> 
    <div id="dlgProfile" class="easyui-dialog" style="width:400px;height:270px;padding:10px 20px"  closed="true" buttons="#dlgProfile-buttons">  
        <form id="fmProfile" class="formStyle"  method="post" novalidate> 
            <div class="fitem">  
                <label>姓名:</label>
                <input type="hidden" name="id" >  
                <input name="nickname" type="text"  class="easyui-validatebox" data-options="required:true" missingMessage="不能为空" >  
            </div>  
            <div class="fitem">  
                <label>Email:</label>  
                <input name="email" type="text"  class="easyui-validatebox" data-options="required:true" validtype="email" missingMessage="不能为空"  invalidMessage="邮箱格式错误" >  
            </div>  
            <div class="fitem">  
                <label>备注:</label>  
                <textarea name="remark" style="height:60px;"></textarea>
            </div>    
        </form>  
    </div>  
    <div id="dlgProfile-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveProfile()">修改</a>  
       	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlgProfile').dialog('close')">取消</a>  
    </div> 
</body>
</html>